#include <iostream>
#include <thread>
#include <functional>

using std::cout;
using std::endl;
using std::thread;
using std::function;
using std::bind;

void threadFunc(int x)
{
    cout << "child thread id " << std::this_thread::get_id() << endl;
    cout << "x = " << x << endl;
}

int main(int argc, char *argv[])
{
    cout << "main thread id " << std::this_thread::get_id() << endl;

    /* function<void()> f = bind(threadFunc, 7); */
    thread th(bind(threadFunc, 7));//th是子线程

    cout << "child thread id = " << th.get_id() << endl;

    th.join();//主线程等待子线程的退出

    return 0;
}

